﻿<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration>Release</Configuration>
    <Gettext>Gettext.Tools.0.21.0.1</Gettext>
    <Project>hc</Project>
  </PropertyGroup>
  <Target Name="UpdatePO">
    <ItemGroup>
      <Sources Include="$(MSBuildProjectDirectory)\hc\*.c" />
      <Sources Include="$(MSBuildProjectDirectory)\hc\*.c" />
      <Sources Include="$(MSBuildProjectDirectory)\l2h\*.c" />
      <Sources Include="$(MSBuildProjectDirectory)\srclib\*.c" />
    </ItemGroup>
	<ItemGroup>
      <Translations Include="$(MSBuildProjectDirectory)\hc\po\*.po" />
    </ItemGroup>
	<Exec 
		Command="..\packages\$(Gettext)\tools\bin\xgettext.exe -k_ -o $(MSBuildProjectDirectory)\hc\po\$(Project).pot --package-name=$(Project) -D po @(Sources->'%(relativedir)%(filename)%(extension)', ' ')" 
		WorkingDirectory="$(MsBuildThisFileDirectory)" />
	<Exec 
		Command="..\packages\$(Gettext)\tools\bin\msgmerge.exe -U %(Translations.Identity) $(MSBuildProjectDirectory)\hc\po\$(Project).pot" 
		WorkingDirectory="$(MsBuildThisFileDirectory)" />
  </Target>
  <Target Name="CompilePO">
	<ItemGroup>
      <Translations Include="$(MSBuildProjectDirectory)\po\*.po" />
    </ItemGroup>
	<Exec Command="..\packages\$(Gettext)\tools\bin\msgfmt.exe %(Translations.Identity) -o $(MSBuildProjectDirectory)/hc/po/%(filename).mo" WorkingDirectory="$(MsBuildThisFileDirectory)" />
  </Target>
  <Target Name="CleanupPO">
	<ItemGroup>
      <TempFiles Include="$(MSBuildProjectDirectory)\hc\po\*.po~" />
    </ItemGroup>
	<Delete Files="@(TempFiles)" />
  </Target>
  <Target Name="InstallPO">
	<ItemGroup>
      <MoFiles Include="$(MSBuildProjectDirectory)\hc\po\*.mo" />
    </ItemGroup>
	<Copy 
		SourceFiles="@(MoFiles)" 
		DestinationFiles="@(MoFiles->'x64\$(Configuration)\%(Filename)\LC_MESSAGES\$(Project).mo')"/>
	<Copy 
		SourceFiles="@(MoFiles)" 
		DestinationFiles="@(MoFiles->'$(Configuration)\%(Filename)\LC_MESSAGES\$(Project).mo')"/>
  </Target>
  <Target Name="LocalizationBuild" DependsOnTargets="UpdatePO;CompilePO;CleanupPO;InstallPO">
  </Target>
 </Project>